package com.freedo.demo.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.springframework.lang.Nullable;

public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public User(){
		this.id= UUID.randomUUID().toString();
		this.name="";
		this.sex="man";
		this.age= 0;
	}
	
	public User(String id,String name,String sex,int age){
		this.id=id;
		this.name=name;
		this.sex=sex;
		this.age= age;
	}
	
	/**
	 * 对象数组转为User对象
	 * @param vals 对象数组
	 * @return
	 */
	public static User fromObject(Object[] vals) {
		return new User((String)vals[0],(String)vals[1],(String)vals[2],(int)vals[3]);
	}
	
	/**
	 * 对象数组列表转为User列表
	 * @param vals 对象数组列表
	 * @return
	 */
	public static List<User> fromObjectList(List<Object> vals){
		List<User> us = new ArrayList<User>();
		for (Object o : vals) {
			us.add(fromObject((Object[])o));
		}
		return us;
	}
	
	private String id;
	@Nullable
	private String name;
	@Nullable
	private String sex;
	@Nullable
	private int age;
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the sex
	 */
	public String getSex() {
		return sex;
	}
	/**
	 * @param sex the sex to set
	 */
	public void setSex(String sex) {
		this.sex = sex;
	}
	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}
	/**
	 * @param age the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}


	
}
